﻿namespace MicroCloud.Identity.Entities
{
    /// <summary>
    /// 实体类：用户登录日志
    /// </summary>
    [Table(nameof(LoginLog),Schema = TableSchemaConstants.Identity)]
    [EventEntityIgnore]
    [Description("用户登录日志")]
    [ValueGenerate(ValueGenerateRule.Never, ValueGenerateMode.Snowflake)]
    public class LoginLog : EntityBase<long>, ICreatedTime
    {
        #region "属性"
        #region "获取或设置 用户编号"
        /// <summary>
        /// 获取或设置 用户编号
        /// </summary>
        [Column("UserId")]
        [DisplayName("用户编号")]
        public long UserId { get; set; }
        #endregion

        #region "获取或设置 登录IP"
        private string _Ip = "";
        /// <summary>
        /// 获取或设置 登录IP
        /// </summary>
        [Column("Ip")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("登录IP")]
        public string Ip { get { return _Ip; } set { _Ip = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 用户代理"
        private string _UserAgent = "";
        /// <summary>
        /// 获取或设置 用户代理
        /// </summary>
        [Column("UserAgent")]
        [StringSize(StringSizeType.General)]
        [DisplayName("用户代理")]
        public string UserAgent { get { return _UserAgent; } set { _UserAgent = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 退出时间"
        /// <summary>
        /// 获取或设置 退出时间
        /// </summary>
        [Column("LogoutTime")]
        [DisplayName("退出时间")]
        public DateTime? LogoutTime { get; set; }
        #endregion

        #region "获取或设置 创建时间 ICreatedTime、ICreationAudited  可装载接口，在数据创建时可自动设置当前时间"
        /// <summary>
        /// 获取或设置 创建时间
        /// </summary>
        [Column("CreatedTime")]
        [DisplayName("创建时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        // 导航属性
        #region "获取或设置 所属用户"
        /// <summary>
        /// 获取或设置 所属用户
        /// </summary>
        [JsonIgnore]
        public virtual User User { get; set; }
        #endregion

        #endregion

    }
}
